orderService.$inject = ['$http'];

function orderService($http) {
    var appContext = require('../../../config/app.context');
    var urlBase = appContext.path + '/api';
    var _orderService = {};

    _orderService.getOrderListByCustomerId = function(cId) {
        return $http.get(urlBase + '/orders/findByCustomerId/' + cId);
    }

    _orderService.getOrderById = function(orderId) {
        return $http.get(urlBase + '/orders/' + orderId);
    }

    _orderService.addOrder = function(order) {
        return $http.post(urlBase + '/orders', order);
    }

    _orderService.confirmOrder = function(orderId) {
        return $http.put(urlBase + '/orders/confirmOrder/' + orderId);
    }

    _orderService.getCommentByOrderId = function(orderId) {
        return $http.get(urlBase + '/comments/getByOrderId/' + orderId);
    }

    _orderService.sendComment = function(comment) {
        return $http.post(urlBase + '/comments', comment);
    }

    return _orderService;
}

module.exports = orderService;